import type { STORAGE_MODES } from '~/views/eeeee/components/constant'
import { request } from '../request'

export async function getElectricityInfo() {
  return request.get(`${SERVICE_ENERGY}/production/electricityInfo`)
}

export async function getEquipmentInfo() {
  return request.get(`${SERVICE_ENERGY}/production/equipmentInfo`)
}

export async function getEquipmentInfoV2() {
  return request.get(`${SERVICE_ENERGY}/production/v2/equipmentInfo`)
}

export async function getConfigData(location?: 0 | 1) {
  return request.get<{
    leftData: { title: string, dataList: { key: string, val: string }[] }[]
    rightData: { title: string, dataList: { key: string, val: string }[] }[]
  }>(`${SERVICE_ENERGY}/production/getConfigData`, {
    params: { location },
  })
}

export async function getConfig(location: 0 | 1) {
  return request.get<{
    id: number
    title: string
    name: string
    location: 0 | 1
    indicatorNumber: string
    timeType: STORAGE_MODES
  }[]>(`${SERVICE_ENERGY}/production/getConfig`, { params: { location } })
}

export async function setConfig(location: 0 | 1, title: string, list: {
  /** 0-左，1-右 */
  location: 0 | 1
  name: string
  indicatorNumber: string
  timeType: STORAGE_MODES
}[]) {
  return request.post(`${SERVICE_ENERGY}/production/config`, { location, title, list })
}
